package datasv.framework_datasv;

import java.rmi.RemoteException;

import org.omg.CORBA.FREE_MEM;

import po.SubModelPO;
import resultmessage.FrameworkRM;

public class AddSubModelReturnID {
	public static void main(String[] args) {
		System.out.println(new AddSubModelReturnID().addSubModelReturnID("001", "0010102", null));
	}
	public String addSubModelReturnID(String collegeID,String modelID,SubModelPO po){
		return addInSql(collegeID,modelID, po);
	}
	private String addInSql(String collegeID,String modelID,SubModelPO po){
		if(!new AddSubModel().addSubModel(collegeID, modelID, po).equals(FrameworkRM.SUCCESS)){
			return "";
		}
		String id=null;
		try {
			int m=new FrameworkDatasvController().getAllSubModelOfModel(collegeID, modelID).size();
			
			id=modelID+"0"+(Integer.toString(m));
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(id==null){
			return "";
		}
		return id;
	}
}
